{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\n",
      "  \"repositories\": [\n",
      "    {\n",
      "      \"url\": \"/Users/allwefantasy/projects/auto-coder\",\n",
      "      \"alias\": \"auto-coder\"\n",
      "    },\n",
      "    {\n",
      "      \"url\": \"/Users/allwefantasy/projects/byzer-llm\",\n",
      "      \"alias\": \"byzer-llm\"\n",
      "    },\n",
      "    {\n",
      "      \"url\": \"/Users/allwefantasy/apps/auto-coder.chat\",\n",
      "      \"alias\": \"auto-coder.chat\"\n",
      "    },\n",
      "    {\n",
      "      \"url\": \"/Users/allwefantasy/apps/video-monkey.chat\",\n",
      "      \"alias\": \"video-monkey.chat\"\n",
      "    },\n",
      "    {\n",
      "      \"url\": \"/Users/allwefantasy/apps/web-typing-auth\",\n",
      "      \"alias\": \"web-typing-auth\"\n",
      "    },\n",
      "    {\n",
      "      \"url\": \"/Users/allwefantasy/projects/video-monkey\",\n",
      "      \"alias\": \"video-monkey\"\n",
      "    },\n",
      "    {\n",
      "      \"url\": \"/Users/allwefantasy/WeChatProjects/long-translate\",\n",
      "      \"alias\": \"long-translate\"\n",
      "    },\n",
      "    {\n",
      "      \"url\": \"/Users/allwefantasy/projects/code_dataset\",\n",
      "      \"alias\": \"code_dataset\"\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "New configuration saved to /Users/allwefantasy/.code_dataset/config.json\n"
     ]
    }
   ],
   "source": [
    "import json\n",
    "\n",
    "# 读取原始配置文件\n",
    "with open('/Users/allwefantasy/.code_dataset/config.json', 'r') as f:\n",
    "    old_config = json.load(f)\n",
    "\n",
    "# 转换配置格式\n",
    "new_config = {\n",
    "    \"repositories\": [\n",
    "        {\"url\": repo, \"alias\": repo.split('/')[-1]} \n",
    "        for repo in old_config[\"repositories\"]\n",
    "    ]\n",
    "}\n",
    "\n",
    "# 打印新的配置\n",
    "print(json.dumps(new_config, indent=2))\n",
    "\n",
    "# 保存新的配置文件\n",
    "with open('/Users/allwefantasy/.code_dataset/config.json', 'w') as f:\n",
    "    json.dump(new_config, f, indent=2)\n",
    "\n",
    "print(\"New configuration saved to /Users/allwefantasy/.code_dataset/config.json\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
